<?php


namespace App\Entity;
use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use Exception;
use Doctrine\ORM\Mapping as ORM;

/**
 * @package App\Entity
 * @ORM\Entity
 * @ORM\Table(name="user")
 * @ORM\HasLifecycleCallbacks
 */
class User
{
    /**
     * @var int
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     * @ORM\Column(type="integer")
     */
    private $id;
    /**
     * @var string|null 对象用户的id
     * @ORM\Column(name="bind_id", type="string",nullable=true, length=100, options={"comment"="对象用户的id"})
     */
    private $bindId;
    /**
     * @var string 恋爱交友code
     * @ORM\Column(name="love_code", type="string", nullable=false, length=100, options={"comment"="恋爱交友code"})
     */
    private $loveCode;
    /**
     * @var string 密码
     * @ORM\Column(name="pwd", type="string",nullable=true, length=100, options={"comment"="密码"})
     */
    private $pwd;
    /**
     * @var string 用户昵称
     * @ORM\Column(name="user_name", type="string",nullable=true, length=100, options={"comment"="用户昵称"})
     */
    private $userName;
    /**
     * @var string 电子邮件
     * @ORM\Column(name="email", type="string",nullable=true, length=100, options={"comment"="电子邮件"})
     */
    private $email;
    /**
     * @var ArrayCollection|null
     * @ORM\ManyToMany(targetEntity="User")
     * @ORM\JoinTable(name="user_for_friend",
     *      joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id",onDelete="CASCADE")},
     *      inverseJoinColumns={@ORM\JoinColumn(name="friend_id", referencedColumnName="id", onDelete="CASCADE")}
     *  )
     */
    private $friends;
    public function __construct()
    {
        $this->friends = new ArrayCollection();
    }

    /**
     * @return int
     */
    public function getId(): int
    {
        return $this->id;
    }
    /**
     * @return string|null
     */
    public function getBindId(): ?string
    {
        return $this->bindId;
    }


    /**
     * @return string
     */
    public function getLoveCode(): string
    {
        return $this->loveCode;
    }


    /**
     * @return string
     */
    public function getUserName(): string
    {
        return $this->userName;
    }

    /**
     * @return string
     */
    public function getEmail(): string
    {
        return $this->email;
    }


    /**
     * @return string
     */
    public function getPwd(): string
    {
        return $this->pwd;
    }


    /**
     * @return array|null
     */
    public function getFriends(): ?array
    {
        return $this->friends->getValues();
    }

    /**
     * @param User|null $friends
     */
    public function setFriends(?User $friends): self
    {
        if (!$this->friends->contains($friends)) {
            $this->friends[] = $friends;
        }
        return $this;
    }

    /**
     * @param string|null $bindId
     * @return User
     */
    public function setBindId(?string $bindId): User
    {
        $this->bindId = $bindId;
        return $this;
    }

    /**
     * @param string $loveCode
     * @return User
     */
    public function setLoveCode(string $loveCode): User
    {
        $this->loveCode = $loveCode;
        return $this;
    }

    /**
     * @param string $pwd
     * @return User
     */
    public function setPwd(string $pwd): User
    {
        $this->pwd = $pwd;
        return $this;
    }

    /**
     * @param string $userName
     * @return User
     */
    public function setUserName(string $userName): User
    {
        $this->userName = $userName;
        return $this;
    }

    /**
     * @param string $email
     * @return User
     */
    public function setEmail(string $email): User
    {
        $this->email = $email;
        return $this;
    }






}
